#pragma once

#include "../core.h"

namespace sfc::time {

constexpr auto MILLIS_PER_SEC = 1000;
constexpr auto MICROS_PER_SEC = 1000000;
constexpr auto NANOS_PER_SEC = 1000000000;

constexpr auto NANOS_PER_MICRO = 1000;
constexpr auto NANOS_PER_MILLI = 1000000;

struct Time {
  i64 _micros;

  auto secs() const -> f64 {
    return f64(_micros) * 1e-9;
  }
};

struct Duration : Time {
  using Time::_micros;
};

struct Instant : Time {
  using Time::_micros;

  static auto now() -> Instant;

  auto operator-(Instant other) const -> Duration {
    return {_micros - other._micros};
  }

  auto operator+(Duration dur) const -> Instant {
    return {_micros - dur._micros};
  }

  auto operator-(Duration dur) const -> Instant {
    return {_micros - dur._micros};
  }
};

struct System : Time {
  using Time::_micros;

  static auto now() -> System;

  auto operator-(System other) const -> Duration {
    return {_micros - other._micros};
  }

  auto operator+(Duration dur) const -> System {
    return {_micros - dur._micros};
  }

  auto operator-(Duration dur) const -> System {
    return {_micros - dur._micros};
  }
};

}  // namespace sfc::time
